package from_0_to_50;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Q015三数之和 {
    static int[] nums = {-1,0,1,2,-1,-4};
    static int[] numss = {-4,-1,-1,0,1,2};
    static int[] aaaa = {0,0,0,0,0};
    public static void main(String[] args) {
        // fun(5);
        List<List<Integer>> list = new ArrayList<>();
        list = threeSum(numss);
    }
    static public List<List<Integer>> threeSum(int[] nums) {
        int len = nums.length;
        List<List<Integer>> lists = new ArrayList<>();
        List<Integer> listSums = new ArrayList<>();
        for (int l = 0; l < len; l++) {
            System.out.print(nums[l]+"\t");
        }
        System.out.println();
        for (int i = 0; i < len; i++) {
            for (int j = i+1; j < len; j++) {
                for (int k = j+1; k < len; k++) {
                    if(nums[i] + nums[j]+ nums[k] == 0){
                        listSums.add(nums[i]);
                        listSums.add(nums[j]);
                        listSums.add(nums[k]);
                        lists.add(listSums);
                        System.out.println(listSums);
                        System.out.println(lists);
                        listSums.clear();
                    }

                }
            }
        }
        return lists;
    }
    public static void fun(int n){
        for (int i = 0; i < 5; i++) {
            for (int j = i+1; j < 5; j++) {
                for (int k = j+1; k < 5; k++) {
                    aaaa[i] = 1;
                    aaaa[j] = 1;
                    aaaa[k] = 1;
                    for (int l = 0; l < 5; l++) {
                        System.out.print(aaaa[l]+"\t");
                    }
                    System.out.println();
                    aaaa[i] = 0;
                    aaaa[j] = 0;
                    aaaa[k] = 0;
                }
            }
        }
    }
}
